package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.marketBean.MarketAdmin;
import com.cskaoyan.bean.marketBean.MarketUser;
import com.cskaoyan.bean.vo.WxglMallManagementControllerVo.CollectListVo;
import com.cskaoyan.mapper.marketMapper.MarketCollectMapper;
import com.cskaoyan.service.WxglCatalogService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author wxgl
 * @date 2023-01-02 00:03
 * @describe
 */
@RequestMapping("wx")
@RestController
public class MJCollectionController {


    @Autowired
    WxglCatalogService wxglCatalogService;

    /**
     * @Author xiaowu
     * @Description //TODO 显示所有的收藏
     * @Date 0:04 2023/1/2
     * @Param http://182.92.235.201:8083/wx/collect/list?type=0&page=1&limit=10
     * @return {"errno":0,"data":{"total":20,"pages":2,"limit":10,"page":1,"list":[{"brief":"1","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/mesvhwbtns0noigmklrq.jpg","valueId":1181096,"name":"222","id":134,"type":0,"retailPrice":0.00},{"brief":"波点娃娃裙搭配面包裤","picUrl":"http://yanxuan.nosdn.127.net/149a09a391ea5a888debf50b9dc4ed7b.png","valueId":1116008,"name":"棉双层纱波点娃娃裙（婴童）","id":133,"type":0,"retailPrice":99.00},{"brief":"来自天然彩棉的礼物","picUrl":"http://yanxuan.nosdn.127.net/9aab9a0bf4fef8fe3dc8c732bc22d4b7.png","valueId":1033000,"name":"新生彩棉初衣礼盒（婴童）","id":132,"type":0,"retailPrice":199.00},{"brief":"null 测试","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/cxpg3qglhm2fxll11w5o.png","valueId":1181040,"name":"null测试","id":131,"type":0,"retailPrice":99999999.00},{"brief":"","picUrl":"","valueId":1181035,"name":"2132323","id":130,"type":0,"retailPrice":0.00},{"brief":"null 测试","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/2bti7do0dzvexwvqs14t.jpg","valueId":1181043,"name":"null 测试","id":129,"type":0,"retailPrice":9999999.00},{"brief":"","picUrl":"","valueId":1181100,"name":"44","id":128,"type":0,"retailPrice":0.00},{"brief":"清凉触感，耐抓耐磨","picUrl":"http://yanxuan.nosdn.127.net/ebe118f94ddafe82c4a8cd51da6ff183.png","valueId":1064000,"name":"清新条纹开放式宠物窝","id":125,"type":0,"retailPrice":79.00},{"brief":"顺滑平面，猫狗通用，去除死毛","picUrl":"http://yanxuan.nosdn.127.net/3bd73b7279a83d1cbb50c0e45778e6d6.png","valueId":1110016,"name":"天然硅胶宠物除毛按摩刷","id":121,"type":0,"retailPrice":39550.00},{"brief":"手办小姐姐","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/cs6cgge8thgp7g14v29q.jpg","valueId":1181017,"name":"手办模型y","id":92,"type":0,"retailPrice":0.00}]},"errmsg":"成功"}
     **/
    @RequestMapping("collect/list")
    public BaseRespVo collectList(BasePageInfo info,Integer type){
        CommonData<CollectListVo> data = wxglCatalogService.collectList(info,type);
        return BaseRespVo.success(data);
    }

    /**
     * @Author xiaowu
     * @Description //TODO 加入或者删除收藏
     * @Date 8:48 2023/1/2
     * @Param [map]  {"type":0,"valueId":1181110}
     * @return {"errno":0,"errmsg":"成功"}
     **/
    @RequestMapping("collect/addordelete")
    public BaseRespVo collectAddordelete(@RequestBody Map map){

        MarketUser principal = (MarketUser) SecurityUtils.getSubject().getPrincipal();
        Integer id = principal.getId();
        wxglCatalogService.collectAddordelete(map,id);
        return BaseRespVo.success();
    }
}
